{% extends 'base.html' %}
{% block content %}
<div class="col-sm-6">
{% if course_records %}
                      <section class="panel">
                          <header class="panel-heading">
                              {{ course_records.0.class_name }}
                          </header>
                          <table class="table table-striped">
                              <thead>
                              <tr>
                                  <th>#</th>
                                  <th>课程名</th>
                                  <th>课时名</th>
                                  <th>上课时间</th>
                                  <th>老师</th>
                                  <th>状态</th>
                                  <th>操作</th>
                              </tr>
                              </thead>
                              <tbody>
                              {% for item in course_records %}
                              <tr>
                                  <td>{{ forloop.counter }}</td>
                                  <td>{{ item.class_name.course.name }}</td>
                                  <td>{{ item.course_content.name }}</td>
                                  <td>{{ item.date }}</td>
                                  <td>{{ item.teacher }}</td>
                                  <td>
                                      {% if course_records.date %}
                                          <span class="label label-primary">已结束</span>
                                        {% else %}
                                          <span class="label label-default">未开始</span>
                                        {% endif %}

                                  </td>

                                  <td>
                                      <!-- Button trigger modal -->
{#                                    <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal" href="/apis/course_record/{{ item.id }}/">#}
                                    <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal" href="{% url 'apis:course_record' item.id %}">
                                      操作
                                    </button>
                                  </td>
                              </tr>
                              {% endfor %}

                              </tbody>
                          </table>
                      </section>
{% else %}
'没有数据'
{% endif %}

</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ... hello world
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
{% endblock %}

{% block loadjs %}
<script>
$(function () {
    $('#myModal').on('hidden.bs.modal', function (e) {
        // do something...
        $(this).removeData("bs.modal");
    })
})
</script>
{% endblock %}
